package com.controller;

import com.controller.vo.ResultVO;
import com.dto.UserCouponDto;
import com.entity.UserCoupon;
import com.service.UserCouponService;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserCouponController
 * @Description 用户优惠券控制层
 * @Author Kx
 * @Date 2025/5/29 11:29
 * @Version 1.0
 */
@RestController
public class UserCouponController extends BaseController{
    private final UserCouponService userCouponService;

    public UserCouponController(UserCouponService userCouponService) {
        this.userCouponService = userCouponService;
    }

    /**
     * @author: kx
     * @date: 2025/5/29 11:29
     * @param userCoupon : 用户优惠券信息
     * @return com.controller.vo.ResultVO<java.lang.String>
     * @description: 添加用户优惠券信息
    */
    @PostMapping("/userCoupon/addUserCoupon")
    public ResultVO<String> addUserCoupon(@RequestBody UserCoupon userCoupon) {
        userCouponService.addUserCoupon(userCoupon);
        return success("添加成功");
    }

    /**
     * @param userId : 用户id
     * @return com.controller.vo.ResultVO<com.dto.UserCouponDto>
     * @author: kx
     * @date: 2025/5/29 15:02
     * @description: 根据用户编查询该用户的所有优惠券信息
     */
    @GetMapping("/userCoupon/findByUserIdAndCouponId")
    public ResultVO<UserCouponDto> findByUserIdAndCouponId(@RequestParam("userId") Integer userId) {
        // 获取用户的所有优惠券信息传输数据对象
        UserCouponDto userCouponDto = userCouponService.findByUserIdAndCouponId(userId);
        return success(userCouponDto);
    }
}
